package com.nuoyuan.wx.common.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * 基础resp dto
 * @param <T>
 */
@Data
public class BaseRespDto<T> implements Serializable {
    
	private static final long serialVersionUID = 1L;
	
	private boolean isSuccess;
    private String code;
    private String msg;
    //数据域
    private T data;


    public BaseRespDto() {   	
    }
    
    public BaseRespDto(boolean isSuccess, String code, String msg) {
        this.isSuccess = isSuccess;
        this.code = code;
        this.msg = msg;
    }

    public BaseRespDto(boolean isSuccess, String code, String msg, T data) {
        this.isSuccess = isSuccess;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public BaseRespDto(String code, String msg) {
        this.isSuccess = false;
        this.code = code;
        this.msg = msg;
    }


    public static BaseRespDto buildErrorResp() {
        return new BaseRespDto(null, null);
    }

    public static BaseRespDto buildErrorResp(String code, String msg) {
        return new BaseRespDto(code, msg);
    }

    public static BaseRespDto buildSuccResp() {
        return new BaseRespDto(true,null, null);
    }
}
